package test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
 * 报文头信息，生产环境需要更改
 * @author mengxx
 *
 */
public class UmsNacHead {
	private static String tpduStr=ChinaUMSZjConfig.tpduStr;
	private static String appcodeStr=ChinaUMSZjConfig.appcodeStr;
	private static int versionInt=ChinaUMSZjConfig.versionInt;
	
	public static byte[] getBytesArray() throws IOException {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		
		byte[] tpdu = BcdCodeUtil.str2cbcd( new UmsNacHead().getTpduStr() );
		byte[] appcode = new String( new UmsNacHead().getAppcodeStr() + (char)0x00).getBytes();
		byte version = (byte)(new UmsNacHead().getVersionInt());
		bos.write(tpdu);
		bos.write(appcode);
		bos.write(version);
		bos.close();
		return bos.toByteArray();
	}

	public String getTpduStr() {
		return tpduStr;
	}

	public void setTpduStr(String tpduStr) {
		UmsNacHead.tpduStr = tpduStr;
	}

	public String getAppcodeStr() {
		return appcodeStr;
	}

	public void setAppcodeStr(String appcodeStr) {
		UmsNacHead.appcodeStr = appcodeStr;
	}

	public int getVersionInt() {
		return versionInt;
	}

	public void setVersionInt(int versionInt) {
		UmsNacHead.versionInt = versionInt;
	}
}
